import reducingBalanceCalculator from './calculate/reducingBalanceCalculator';
import straightLineCalculator from './calculate/straightLineCalculator';
import { ELOAN_TYPE, ICalculator, IRepaymentSchedule } from './types';

/**
 * 付款类型映射
 */
export const REPORT_TITLE_CN = new Map<ELOAN_TYPE, string>([
  [ELOAN_TYPE.reducingBalance, '等额本金'],
  [ELOAN_TYPE.straightLine, '等额本息'],
]);


const repaymentTypeText = Object.keys(ELOAN_TYPE)
  .map((type) => {
    const key = ELOAN_TYPE[type];
    return `${key}.${REPORT_TITLE_CN.get(key)}`;
  })
  .join(' ');


/**
 * 输入问题表
 */
export const QUESTIONS_MAP = {
  principal: '请输入贷款本金（元）：',
  interestRate: '请输入年利率（%）：',
  loanTerm: '请输入贷款期限（月）：',
  repaymentDate: '请输入开始还款时间（YYYY-MM-DD, 默认今天）：',
  repaymentType: `请选择还款方式（${repaymentTypeText}）`,
};


/**
 * 计算方式映射
 */
export const calculatorsMap = new Map<ELOAN_TYPE, ICalculator>([
  [ELOAN_TYPE.reducingBalance, reducingBalanceCalculator],
  [ELOAN_TYPE.straightLine, straightLineCalculator],
]);


export const REPORT_RESULT_CN: Array<[keyof IRepaymentSchedule, string]> = [
  ['repaymentDate', '还款日期'],
  ['monthlyPayment', '还款金额'],
  ['interestPayment', '本月利息'],
  ['monthlyPrincipal', '本月本金'],
  ['remainingPrincipal', '剩余本金'],
];


